<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="js/vue.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="con"  @keyup.enter="tj">
        <button @click="tj" >添加</button>
        <div v-for="(item,index) in mag">
            <span>{{item.id}}</span>
            <span>{{item.name}}</span>
            <button @click="sc(index)">删除</button>
        </div>
    </div>

    <script>
      var app = new Vue({
          el:"#app",
          data:{
              con:"",
              mag:[
                  {"id":1,"name":"吃饭饭"},
                  {"id":2,"name":"睡觉觉"},
                  {"id":3,"name":"打豆豆"},
              ],
          },
        methods:{
                tj:function(){
                    var mydo = this.mag.length;
                    this.mag.push({
                        id:mydo+1,
                        name:this.con
                    }),
                    this.con = ""
                },
                sc:function(index){
                    this.mag.splice(index,1)
                }
              
          }
      })
    </script>
</body>
</html>